package com.lemon.smartsafetynew.ui.fragment.record;

import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;

import android.support.v7.widget.RecyclerView;
import android.util.Log;

import com.google.gson.Gson;
import com.lemon.smartsafety.R;
import com.lemon.smartsafety.data.app.DataUtil;
import com.lemon.smartsafety.listener.RecyclerTClickListener;
import com.lemon.smartsafetynew.ui.fragment.base.BaseFragment;
import com.lemon.smartsafety.utils.app.UIHelper;
import com.lemon.smartsafetynew.entity.record.FunctionVo;
import com.lemon.smartsafetynew.ui.activity.record.CompanySearchActivity;
import com.lemon.smartsafetynew.ui.adapter.record.RecordFunctionGridAdapter;
import com.lemon.smartsafetynew.util.constants.KeyConstants;

import java.util.List;
import butterknife.Bind;
/**
 * Created by lzh on 2018/3/16.
 */
public class DocsListFragment extends BaseFragment
        implements RecyclerTClickListener<FunctionVo>  {

    @Bind(R.id.recyclerView)
    RecyclerView recyclerView;

    private Gson gson = new Gson();
    private RecordFunctionGridAdapter mRecordFunctionGridAdapter;
    private String searchParams = "";

    public static DocsListFragment newInstance() {

        Bundle args = new Bundle();

        DocsListFragment fragment = new DocsListFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected void getBaseArguments() {

    }

    @Override
    protected int getContentViewId() {
        return R.layout.fragment_docs_list;
    }

    @Override
    protected void initViews() {
        List<FunctionVo> functionVoList = DataUtil.getFunctionList();
        mRecordFunctionGridAdapter = new RecordFunctionGridAdapter(functionVoList, this);
        GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 3);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(mRecordFunctionGridAdapter);
    }

    @Override
    public void onItemClick(FunctionVo data, int position) {
        Bundle bundle = new Bundle();
        bundle.putSerializable(KeyConstants.KEY_DOCS_VO, data);
        UIHelper.showActivity(getmContext(), bundle, CompanySearchActivity.class);
    }


}
